<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="<%=basePath%>vendors/jquery/jquery.min.js"></script>
<title>add user</title>
<script type="text/javascript">
	function add() {
		var url = "<%=basePath%>/api/user/add";
		var datas = {
			userName : $("#userName").val(),
			loginName : $("#loginName").val(),
			loginPassword : $("#loginPassword").val(),
			mobilephone : $("#mobilephone").val(),
		};

		$.ajax({
			type : 'POST',
			cache : false,
			url : url,
			data : datas,
			async : false,
			success : function(result) {
				$("#message").html(result.message);
				if (result.code == 1) {
					window.location = "<%=basePath%>user/list";
				}
			},
			error : function(result) {
				alert(result);
			}
		});
	}
</script>
</head>
<body>
	<form id="loginForm" action="<%=basePath%>api/user/add" method="post">
		userName : <input type="text" id="userName" name="userName"><br>
		loginName : <input type="text" id="loginName" name="loginUsername"><br> 
		loginPassword : <input type="text" id="loginPassword" name="loginPassword"><br>
		mobilephone : <input type="text" id="mobilephone" name="mobilephone"><br>
		<a href="javascript:add();">Submit</a> <a href="<%=basePath%>/user/list">Return</a>
	</form>
	<p id="message"></p>
</body>
</html>